package com.asset.dispoal.business.bsAssetInstitutionBatch;

import com.asset.dispoal.business.bsAssetInstitutionBatch.api.IBsAssetInstitutionBatchService;
import com.asset.dispoal.business.bsAssetInstitutionBatch.dto.BsAssetInstitutionBatchRequest;
import com.asset.dispoal.business.bsAssetInstitutionBatch.dto.BsAssetInstitutionBatchResponse;
import com.asset.dispoal.business.bsAssetInstitutionBatch.dto.BsAssetInstitutionPolicyRequest;
import com.asset.dispoal.business.bsAssetInstitutionBatch.dto.BsAssetInstitutionPolicyResponse;
import com.asset.dispoal.logger.annoation.SysLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import tech.mhuang.pacebox.springboot.core.controller.BaseController;
import tech.mhuang.pacebox.springboot.core.permission.annotation.Permission;
import tech.mhuang.pacebox.springboot.protocol.Result;
import tech.mhuang.pacebox.springboot.protocol.data.PageVO;

/**
 * 资产机构批次表控制层
 *
 * @author: mhuang
 * @date: 2022-03-10 09:40:20
 */
@RestController
@Api(value = "种类配置管理", tags = "种类配置管理")
@RequestMapping("business/bsAssetInstitutionBatch")
public class BsAssetInstitutionBatchController extends BaseController {

    @Autowired
    private IBsAssetInstitutionBatchService bsAssetInstitutionBatchService;

    //    @Permission(code = "systemTypeconfig:query", param = "t.create_user")
    @GetMapping(value = "/page")
    public Result<PageVO<BsAssetInstitutionBatchResponse>> page(BsAssetInstitutionBatchRequest request) {
        return bsAssetInstitutionBatchService.queryPage(request);
    }

    @Permission(code = "systemTypeconfig:add")
    @PostMapping(value = "/insert")
    public Result insert(@RequestBody BsAssetInstitutionBatchRequest request) {
        bsAssetInstitutionBatchService.insert(request);
        return Result.ok();
    }

    @Permission(code = "systemTypeconfig:update")
    @PutMapping(value = "/update")
    public Result update(@RequestBody BsAssetInstitutionBatchRequest request) {
        bsAssetInstitutionBatchService.update(request);
        return Result.ok();
    }

    @Permission(code = "systemTypeconfig:del")
    @PostMapping(value = "/delete")
    public Result delete(@RequestBody BsAssetInstitutionBatchRequest request) {
        bsAssetInstitutionBatchService.update(request);
        return null;
    }

    @PostMapping(value = "/createPolicy")
    @ApiOperation(value = "新增优惠政策", notes = "新增优惠政策")
    @SysLog(name = "新增优惠政策")
    public Result createPolicy(@RequestBody BsAssetInstitutionPolicyRequest request) {
        bsAssetInstitutionBatchService.createPolicy(request);
        return Result.ok();
    }

    @GetMapping(value = "/getPolicyById")
    @ApiOperation(value = "优惠政策信息接口", notes = "优惠政策信息")
    public Result<BsAssetInstitutionPolicyResponse> policyInfo(String id) {
        return bsAssetInstitutionBatchService.getPolicyById(id);
    }
}